<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="../lib/vue.js"></script>
  <script src="../lib/vue-route.js"></script>
</head>

<body>
  <div id="app">
    <router-link to="/login?id=1&name=xiaoming">登录</router-link>
    <router-link to="/register">注册</router-link>

    <router-view/>
  </div>

  <script>
    //组件的模板对象
    var login = {
      template: '<h1>登录 {{this.$route.query.id}}  {{this.$route.query.name}}</h1>',
      created() {
          //组件的生命周期
          console.log(this.$route)
      },
    }
    var register = {
      template: '<h1>注册组件</h1>'
    }


    var routerObj = new VueRouter({
        routes: [{
            path: '/login',
            component: login
        }, {
            path: '/register',
            component: register
        }]
    })


    // 创建Vue实例，得到ViewModel
    var vm = new Vue({
      el: '#app',
      data: {},
      methods: {},
      router: routerObj
    });
  </script>
</body>

</html>